<template>
  <div>
    <div style="width: 100px;height: 50px "><span style="width: 100%;height: 100%;line-height: 50px;color: royalblue">申请情况</span></div>
    <div>
      <el-table :data="tableData" style="width: 100%" height="725px">
        <el-table-column prop="wid" label="工作室号 "width="180"></el-table-column>
        <el-table-column prop="projectName" label="工作室名" width="180"></el-table-column>
        <el-table-column prop="price" label="报价"></el-table-column>
        <el-table-column prop="timeLimit" label="工期"></el-table-column>
        <el-table-column prop="xq" label="申请组织属性"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">

            <el-button
              size="mini"
              @click="handleEdit(scope.$index, scope.row)">详情情况</el-button>
            <el-button
              size="mini"
              @click="handleEditt(scope.$index, scope.row)">同意</el-button>
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)">拒绝</el-button>
          </template>
        </el-table-column>
      </el-table>

    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        pid:'',
        tableData: [
          {
            gid:'',
            id:'',
            wid:'',
            projectName:'',
            price:'',
            timeLimit:'',
            xq:'',
            tid:''
          }
        ]
      }
    },
    mounted: function(){
     var pid= this.$route.query.mallCode
     this.pid=this.$route.query.mallCode
      axios.post('/company/findApplyProject',{
        id : pid,
        pid:pid
      }).then((response) => {
        console.log(response.data)
        if( response.data != null){
          this.$notify({
            title: '成功',
            message: '成功',
            type: 'success',
            duration:2000
          });
          var e=response.data
          var data=[];
          for(var c=0;c<e.length;c++){

            var ee=e[c];
            var obj={}
            obj.id=ee.id
            obj.wid=ee.wid
            obj.projectName=ee.projectName
            obj.price=ee.price
            var ff=ee.timeLimit

            let zz=ff.split("T")


            var z=zz[0]
            console.log(z)
            obj.timeLimit=z
            obj.gid=ee.style
            if(ee.tid==0){
              obj.xq="工作室"
            }else{
              obj.xq="工作室联盟"
            }

            obj.tid=ee.tid

            data[c]=obj
            console.log(obj)
          }
          console.log(data)
          this. tableData=data


        }
        else{
          this.$notify({
            title: '失败',
            message: '错误',
            type: 'warning',
            duration:2000
          });
        }
      })

    },
    methods: {
      handleEdit(index, row) {


        let ff=row.gid

        let xq=row.xq



        if(ff==0&&xq==="工作室"){
          this.$router.push({
            path: '/Workroom',
            query: {
              mallCode:row.wid,
            }
          })
        }else if(ff!=0&&xq==="工作室"){

          this.$router.push({
            path: '/GroupM',
            query: {
              mallCode:row.gid,
            }
          })
        }else {

          this.$router.push({
            path: '/TeamMe',
            query: {
              mallCode:row.tid,
            }
          })
        }
        console.log(row.wid)


      },

      handleEditt(index, row) {
        console.log(row.wid)
        var ee=row.wid
        axios.post('/company/acceptProjectApply',{
          wid : ee,
          pid  : this.pid,
          style:row.gid
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });

            location.reload()
          } else{
            this.$notify({
              title: '失败',
              message: '操作失败',
              type: 'warning',
              duration:2000
            });
          }
        })


      },
      handleDelete(index, row) {

        var ff=row.id
        var a="1"
        console.log(ff)
        console.log(a)
        axios.post('/company/deleteProjectApply',{
          wid : ff,
          states : a
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });
            location.reload()
          }
          else{
            this.$notify({
              title: '失败',
              message: '操作错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      }

    }}
</script>

<style scoped>

</style>
